#include <cmath>
#include <cstdio>

typedef long long ll;
const int N = 1e7 + 5;
int n, cnt;
ll m;
int pri[N], minfact[N];
bool vis[N], nsqr[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("math.in", "r", stdin);
  freopen("math.out", "w", stdout);
#endif
#endif

  scanf("%d%lld", &n, &m);
  nsqr[1] = true;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) { pri[++cnt] = i, minfact[i] = cnt, nsqr[i] = true; }
    for (int j = 1; j <= cnt && pri[j] * i <= n; ++j) {
      vis[i * pri[j]] = true;
      minfact[i * pri[j]] = j;
      if (minfact[i] == j) break;
      nsqr[pri[j] * i] = nsqr[i];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (nsqr[i]) {
      ans += ((int)sqrt(n / i)) * (((ll)sqrt(m / i)) & 1 ? -1 : 1);
    }
  }
  printf("%d", ans);
  return 0;
}